package chan.project.service;

import chan.project.model.dto.picture.PictureQueryRequest;
import chan.project.model.dto.picture.PictureReviewRequest;
import chan.project.model.dto.picture.PictureUploadRequest;
import chan.project.model.entity.User;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import chan.project.model.entity.Picture;
import chan.project.model.vo.PictureVO;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;

/**
 * 图片上传服务
 *
 * @author <a href="https://github.com/kavansp">kavansp</a>
 * @from <a href="https://www.code-nav.cn">编程导航学习圈</a>
 */
public interface PictureService extends IService<Picture> {

    /**
     * 校验数据
     *
     * @param picture
     * @param add 对创建的数据进行校验
     */
    void validPicture(Picture picture, boolean add);

    /**
     * 获取查询条件
     *
     * @param pictureQueryRequest
     * @return
     */
    QueryWrapper<Picture> getQueryWrapper(PictureQueryRequest pictureQueryRequest);
    
    /**
     * 获取图片上传封装
     *
     * @param picture
     * @param request
     * @return
     */
    PictureVO getPictureVO(Picture picture, HttpServletRequest request);

    /**
     * 上传图片
     *
     * @param multipartFile
     * @param pictureUploadRequest
     * @param loginUser
     * @return
     */
    PictureVO uploadPicture(MultipartFile multipartFile,
                            PictureUploadRequest pictureUploadRequest,
                            User loginUser);


    PictureVO uploadPictureByUrl(String url, PictureUploadRequest pictureUploadRequest, User loginUser);

    /**
     * 分页获取图片上传封装
     *
     * @param picturePage
     * @param request
     * @return
     */
    Page<PictureVO> getPictureVOPage(Page<Picture> picturePage, HttpServletRequest request);

    /**
     * 管理员审核图片
     * @param pictureReviewRequest
     * @param loginUser
     * @return
     */
    void doPictureReview(PictureReviewRequest pictureReviewRequest, User loginUser);

    Picture fillReviewMessage(Picture picture, User loginUser);
}
